import {
  exportUrl,
  downloadTemplateUrl,
  getBarcodePrintTempList,
  getPrinttypeList
} from "@/api/print/mesMaterialprintHistory"

import { exportExcel } from "@/utils/judge"

// 列表头按钮配置
export const operateList = [
  {
    name: $i18n.t("common.export"),
    type: "primary",
    icon: "el-icon-download",
    handleName: "export", //点击时返回的标识
    url: exportUrl
    //auth: "auth:operlog:export", //权限字段
  },
  {
    name: $i18n.t("mesMaterialPrintHistory.reprint"),
    type: "primary",
    icon: "el-icon-printer",
    handleName: "repairPrint", //点击时返回的标识
    //auth: "auth:operlog:export", //权限字段
    //是否可点击；
    disabled: (data) => {
      return data == 0
    }
  }
]
// 行末按钮配置
export const rowConfig = [
  {
    name: $i18n.t("common.details"),
    type: "info",
    class: "row-btn-info",
    handleName: "detail" //点击时返回的标识
  }
]
// 搜索条件配置
export const searchConfig = {
  inline: true,
  formDesc: {
    printtype: {
      type: "select",
      label: $i18n.t("mesMaterialPrintHistory.printType"),
      prop: {
        value: "value",
        text: "description"
      },
      options: async (data) => {
        const list = await getPrinttypeList()
        return list.data.result
      }
    },
    printTemp: {
      type: "select",
      label: $i18n.t("mesMaterialPrintHistory.printTemp"),
      prop: {
        value: "templateName",
        text: "templateName"
      },
      options: async (data) => {
        const list = await getBarcodePrintTempList()
        return list.data.result
      }
    },
    planCode: {
      type: "input",
      label: $i18n.t("mesMaterialPrintHistory.planCode")
    },
    orderCode: {
      type: "input",
      label: $i18n.t("mesMaterialPrintHistory.orderCode")
    },
    prodCode: {
      type: "input",
      label: $i18n.t("mesMaterialPrintHistory.prodCode")
    },
    curProcessName: {
      type: "input",
      label: $i18n.t("mesMaterialPrintHistory.curProcessName")
    },
    nextProcessName: {
      type: "input",
      label: $i18n.t("mesMaterialPrintHistory.nextProcessName")
    },
    equipmentCode: {
      type: "input",
      label: $i18n.t("mesMaterialPrintHistory.equipmentCode")
    },

    printtime: {
      type: "datetimerange",

      label: $i18n.t("mesMaterialPrintHistory.printTime"),
      attrs: {
        valueFormat: "yyyy-MM-dd HH:mm:ss",
        searchArrKey: ["printtimeMin", "printtimeMax"]
      }
    }
  }
}
// 新增/删除表单配置
export const formDescDialog = {
  span: 24,
  disabled: false,
  isShowSubmitBtn: true,
  formDesc: {
    planCode: {
      type: "input",
      label: $i18n.t("mesMaterialPrintHistory.planCode"),
      layout: 12,
      required: false
    },
    orderCode: {
      type: "input",
      label: $i18n.t("mesMaterialPrintHistory.orderCode"),
      layout: 12,
      required: false
    },
    prodCode: {
      type: "input",
      label: $i18n.t("mesMaterialPrintHistory.prodCode"),
      layout: 12,
      required: false
    },
    prodName: {
      type: "input",
      label: $i18n.t("mesMaterialPrintHistory.prodName"),
      layout: 12,
      required: false
    },
    quantity: {
      type: "number",
      label: $i18n.t("mesMaterialPrintHistory.quantity"),
      layout: 12,
      required: false
    },
    pieceWeight: {
      type: "number",
      label: $i18n.t("mesMaterialPrintHistory.pieceWeight"),
      layout: 12,
      required: false
    },
    grossWeight: {
      type: "number",
      label: $i18n.t("mesMaterialPrintHistory.grossWeight"),
      layout: 12,
      required: false
    },
    curProcessCode: {
      type: "input",
      label: $i18n.t("mesMaterialPrintHistory.curProcessCode"),
      layout: 12,
      required: false
    },
    curProcessName: {
      type: "input",
      label: $i18n.t("mesMaterialPrintHistory.curProcessName"),
      layout: 12,
      required: false
    },
    nextProcessCode: {
      type: "input",
      label: $i18n.t("mesMaterialPrintHistory.nextProcessCode"),
      layout: 12,
      required: false
    },
    nextProcessName: {
      type: "input",
      label: $i18n.t("mesMaterialPrintHistory.nextProcessName"),
      layout: 12,
      required: false
    },
    materialCode: {
      type: "input",
      label: $i18n.t("mesMaterialPrintHistory.materialCode"),
      layout: 12,
      required: false
    },
    equipmentCode: {
      type: "input",
      label: $i18n.t("mesMaterialPrintHistory.equipmentCode"),
      layout: 12,
      required: false
    },
    operatorBy: {
      type: "input",
      label: $i18n.t("mesMaterialPrintHistory.operatorBy"),
      layout: 12,
      required: false
    },
    operatorByName: {
      type: "input",
      label: $i18n.t("mesMaterialPrintHistory.operatorByName"),
      layout: 12,
      required: false
    },
    materialChargeNumber: {
      type: "input",
      label: $i18n.t("mesMaterialPrintHistory.materialChargeNumber"),
      layout: 12,
      required: false
    },
    finishDate: {
      type: "date",
      label: $i18n.t("mesMaterialPrintHistory.finishDate"),
      layout: 12,
      required: false,
      attrs: {
        valueFormat: "yyyy-MM-dd"
      }
    },
    boxcode: {
      type: "input",
      label: $i18n.t("mesMaterialPrintHistory.boxCode"),
      layout: 12,
      required: false
    },
    boxNumber: {
      type: "number",
      label: $i18n.t("mesMaterialPrintHistory.boxNumber"),
      layout: 12,
      required: false
    },
    boxTotal: {
      type: "number",
      label: $i18n.t("mesMaterialPrintHistory.boxTotal"),
      layout: 12,
      required: false
    },
    transferBillNumber: {
      type: "input",
      label: $i18n.t("mesMaterialPrintHistory.transferBillNumber"),
      layout: 12,
      required: false
    },
    inspectionResult: {
      type: "input",
      label: $i18n.t("mesMaterialPrintHistory.inspectionResult"),
      layout: 12,
      required: false
    },
    printTemp: {
      type: "input",
      label: $i18n.t("mesMaterialPrintHistory.printTemp"),
      layout: 12,
      required: false
    },
    printtime: {
      type: "datetime",
      label: $i18n.t("mesMaterialPrintHistory.printTime"),
      layout: 12,
      required: false,
      attrs: {
        valueFormat: "yyyy-MM-dd HH:mm:ss"
      }
    },
    printtype: {
      type: "select",
      label: $i18n.t("mesMaterialPrintHistory.printType"),
      layout: 12,
      required: false,
      prop: {
        value: "value",
        text: "description"
      },
      options: async (data) => {
        const list = await getPrinttypeList()
        return list.data.result
      }
    },
    // printBy: {
    //   type: "input",
    //   label: "打印人员工号",
    //   layout: 12,
    //   required: false,
    // },
    printByName: {
      type: "input",
      label: $i18n.t("mesMaterialPrintHistory.printByName"),
      layout: 12,
      required: false
    },
    // scanIds: {
    //   type: "input",
    //   label: "扫描明细表id",
    //   layout: 12,
    //   required: false,
    // },
    remark: {
      type: "input",
      label: $i18n.t("common.remark"),
      layout: 24,
      required: false
    }
  }
}
//导入数据
export const importFormDescDialog = {
  span: 24,
  disabled: false,
  isShowSubmitBtn: true,
  formDesc: {
    model: {
      type: "button",
      label: "",
      layout: 24,
      required: false,
      title: $i18n.t('common.downloadTemplate'),
      style: {
        color: "#1867c0",
        fontSize: "14px"
      },
      on: {
        click: () => {
          exportExcel(downloadTemplateUrl)
        }
      }
    },
    file: {
      type: "input",
      label: $i18n.t("mesMaterialPrintHistory.file"),
      layout: 24
      // required: true,
    }
  }
}
